home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
LOC
/
ZLOCDOC.C
< prev
next >
Wrap
Text File
|
1991-10-17
|
3KB
|
154 lines
/* zLOCDoc.c -- document methods */
/* Created 10/17/91 4:10 PM by AppMaker */
/* We recommend that you not modify this module and instead modify */
/* its subclass, LOCDoc. The 'z' prefix on this module marks */
/* a module which is likely to be regenerated by AppMaker after you */
/* make changes to the user interface. The modules without the 'z' */
/* prefix will not be regenerated by AppMaker unless you delete them. */
/* Using a separate subclass to override the AppMaker-generated code */
/* lets you regenerate code without losing your hand-coded changes. */
#include <Commands.h>
#include <Global.h>
#include <CApplication.h>
#include <CBartender.h>
#include <CDataFile.h>
#include <CDecorator.h>
#include <CDesktop.h>
#include <CError.h>
#include <TBUtilities.h>
#include "LOCCounter.h"
#include "zLOCDoc.h"
extern CApplication *gApplication; /* The application */
extern CBartender *gBartender; /* The menu handling object */
extern CDecorator *gDecorator; /* Window dressing object */
extern CBureaucrat *gGopher; /* The current boss in the chain of command */
extern CError *gError; /* The error handling object */
extern OSType gSignature; /* The application's signature */
/*----------*/
void ZLOCDoc::ILOCDoc (
CApplication *aSupervisor,
Boolean printable)
{
CDocument::IDocument (aSupervisor, printable);
itsLOCCounter = NULL;
} /* ILOCDoc */
/*----------*/
Boolean ZLOCDoc::ReadData (Handle *theData)
{
return (FALSE);
} /* ReadData */
/*----------*/
void ZLOCDoc::WriteData (void)
{
/* application-specific write data to itsFile */
} /* WriteData */
/*----------*/
void ZLOCDoc::NewFile (void)
{
BuildWindows ();
itsWindow->Select ();
} /* NewFile */
/*----------*/
void ZLOCDoc::OpenFile (SFReply *macSFReply)
{
CDataFile *theFile;
Handle theData;
Str63 theName;
OSErr theError;
theFile = new (CDataFile);
theFile->IDataFile ();
theFile->SFSpecify (macSFReply);
itsFile = theFile;
theError = theFile->Open (fsRdWrPerm);
if (!gError->CheckOSError (theError)) {
Dispose ();
return;
}
if (!ReadData (&theData)) {
Dispose ();
return;
}
BuildWindows ();
DisposHandle (theData);
itsFile->GetName (theName);
itsWindow->SetTitle (theName);
itsWindow->Select ();
} /* OpenFile */
/*----------*/
void ZLOCDoc::BuildWindows (void)
{
itsLOCCounter = new (CLOCCounter);
itsLOCCounter->ILOCCounter (this);
itsMainPane = itsLOCCounter->itsMainPane;
itsWindow = itsLOCCounter;
} /* BuildWindows */
/*----------*/
Boolean ZLOCDoc::DoSave (void)
{
if (itsFile == NULL) {
return (DoSaveFileAs ());
} else {
WriteData ();
dirty = FALSE;
gBartender->DisableCmd (cmdSave);
return (TRUE);
}
} /* DoSave */
/*----------*/
Boolean ZLOCDoc::DoSaveAs (SFReply *macSFReply)
{
CDataFile *theFile;
if (itsFile != NULL) {
itsFile->Dispose ();
}
theFile = new (CDataFile);
theFile->IDataFile ();
theFile->SFSpecify (macSFReply);
itsFile = theFile;
theFile->CreateNew (gSignature, 'TEXT');
theFile->Open (fsRdWrPerm);
itsWindow->SetTitle (macSFReply->fName);
return (DoSave ());
} /* DoSaveAs */
/*----------*/
void ZLOCDoc::DoCommand (long theCommand)
{
switch (theCommand) {
case cmdClose:
CloseWind (itsWindow);
break;
default:
inherited::DoCommand (theCommand);
break;
} /* switch */
} /* DoCommand */
/* zLOCDoc.c */